﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;


namespace ConwaysGameOfLife
{
    public class Grid
    {
        private List<List<int>> _grid = null;
        private int WIDTH;
        private int HEIGHT;
        public int GetWidth
        {
            get { return WIDTH; }
        }
        public int GetHeight
        {
            get { return HEIGHT; }
        }
        public List<List<int>> _GetGrid
        {
            get{return _grid;}
            set { _grid = value; }
        }

        public void SetStateOfCell(int x, int y, int state)
        {

            if (x > 0 && x < _grid.Count)
            {
                if (y > 0 && y < _grid[0].Count)
                {
                    _grid[x][y] = state;
                }
            }
           
        }
        

        public Grid(Vector2 size)
        {
            WIDTH = (int)size.X;
            HEIGHT = (int)size.Y;

                _grid = _grid = new List<List<int>>();

                for (int x = 0; x < WIDTH; x++)
                {
                    _grid.Add(new List<int>());
                    for (int y = 0; y < HEIGHT; y++)
                    {
                        _grid[x].Add(0);
                    }
                }
            
        }
        public int _GetStateOfCell(int x ,int y)
        {
            if (x > 0 && x < _grid.Count)
            {
                if (y > 0 && y < _grid[0].Count)
                {
                    return _grid[x][y];
                }
            }
            return 0;
        }
        public void ClearGrid()
        {
            for (int x = 0; x < WIDTH; x++)
            {
                
                for (int y = 0; y < HEIGHT; y++)
                {
                    _grid[x][y] = 0 ;
                }
            }
        }

    }
}
